home *** CD-ROM | disk | FTP | other *** search
- Path: fnnews.fnal.gov!berg
- From: berg@fsui01.fnal.gov (David Berg)
- Newsgroups: comp.lang.c,comp.std.c
- Subject: atexit() internals under Unix
- Followup-To: poster
- Date: 15 Mar 1996 22:18:30 GMT
- Organization: FERMILAB, Batavia, IL
- Distribution: world
- Message-ID: <4icqbm$pk9@fnnews.fnal.gov>
- NNTP-Posting-Host: fsui01.fnal.gov
- X-newsreader: xrn 8.01
-
- I have a some questions regarding ANSI C in a Unix (or POSIX) context.
- They all relate to exit handling. I don't have a copy of the ANSI C
- standard, nor have I been able to find more than cursory explanations
- in other reference sources.
-
- 1. Suppose a process registers an exit handler with atexit(). The exit
- handler, in turn, calls some application library routines, which call
- others that are also called from the mainline of the program. Leaving
- the issue of re-entrancy aside, is there any general way (eg, a system
- service call) by which the function can determine that it was called
- in the context of an exit handler? Can it access the exit status with
- which exit() was called?
-
- 2. Same as above, except the process registers a signal handler with
- sigaction(). Can a lower level function determine that it was called
- in the context of a signal handler? What if the signal handler calls
- exit()?
-
- 3. Suppose the process now forks. From experimentation, it appears that
- exit handlers, like signal handlers, are inherited by the child. Is
- this behavior standard (though beyond the scope of ANSI), or at least
- conventional?
-
- 4. If an exit handler calls exit(), is the handler called recursively? Or
- has it been unregistered before it is invoked? (Again, it would appear
- from experimentation that it is indeed unregistered.)
-
- Thanks.
-
- ---------------------------+-----------------------------------------
- "A nanosecond here, | David M. Berg (berg@fnal.gov)
- a nanosecond there, | Computing Division
- and pretty soon you're | Fermilab MS120
- talking about Real Time." | PO Box 500 tel: 708-840-3021
- (apologies to the late | Batavia IL 60510 fax: 708-840-2783
- Sen. Everett Dirksen) |
-